package cn.lut.springboot.api;

import cn.lut.springboot.entity.Employee;
import cn.lut.springboot.factory.MyFallBackFactory;
import cn.lut.springboot.util.ResultEntity;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

/**
 * @user:dell
 * @date:2021年01月06 10:47
 */
//@FeignClient注解表示当前接口和一个provider对应，注解中value属性指定要调用的provider的微服务名称
//    注解中的allbackFactory属性指定Provider不可用时提供备用方案的工厂类型
@FeignClient(value = "atlut-provider",fallbackFactory = MyFallBackFactory.class)
public interface EmployeeRemoteService {
//    远程调用的接口方法，要求：要和 @RequestMapping注解映射的地址一致
//    要求方法声明一致
//    要求获取请求参数，@PathVariable，@RequestParam，@RequestBody等注解不能省略，要求一致
    @RequestMapping("/provider/get/employee/remote")
    public Employee getEmployeeRemote();

    @RequestMapping("/provider/get/employee/by/id")
    List<Employee> getEmpListRemote(@RequestParam("keyword") String keyword);

    @RequestMapping("/provider/get/emp/with/circuit/breaker")
    public ResultEntity<Employee> getEmpWithCircuitBreaker(@RequestParam("signal") String signal);
}
